home *** CD-ROM | disk | FTP | other *** search
- #include <WM.h>
- #include <MyStructs.h>
- #include <Menu.h>
-
- USHORT OpenMWin(struct NewWindow *window,struct IntuiText *tx)
- {
- HEIGHTBuff[0]=0;
- WIDTHBuff[0]=0;
- TOPBuff[0]=0;
- LEFTBuff[0]=0;
- DEPTHBuff[0]=0;
- TITLEBuff[0]=0;
- if(!(Mwin=(struct Window *)OpenWindow(window))) return(1);
- Mrp=Mwin->RPort;
- WinBorder(Mwin);
- SetFont(Mrp,StdFont);
- PrintIText(Mrp,tx,0,0);
- MenuOn(0);
- return(0);
- }
- VOID MWinOn(struct Window *win)
- {
- if(win->MenuStrip) ClearMenuStrip(win);
- CloseWindow(win);
- }
- USHORT DefMenu()
- {
- USHORT quit=FALSE;
- if(sc->Width < ItemWindow.Width || sc->Height < ItemWindow.Height || sc==WMsc)
- {
- ScreenToFront(WMsc);
- WMsc->Font=sc->Font;
- activS=WMsc;
- x=165;
- }
- else
- {
- activS=sc;
- if(sc->Width == 320 || (sc->Width > 320 &&
- (sc->ViewPort.Modes & HIRES)==0)) x=5;
- else if(sc->Width == 640 && (sc->ViewPort.Modes & HIRES)) x=165;
- else x=0;
- }
- MenuWindow.Screen=activS;
- ItemWindow.Screen=activS;
- MenuWindow.LeftEdge=x;
- ItemWindow.LeftEdge=x;
- amenu=awin->MenuStrip;
- firstM=amenu;
- lastM=amenu;
- Manz=0;
- Mnr=0;
- while(amenu)
- {
- lastM=amenu;
- Manz++;
- amenu=amenu->Next;
- if(Manz > 9) Mnr++;
- }
- amenu=lastM;
- if(amenu==NULL) NoMenu();
- else HolItem();
- OldMenu=amenu;
- OldItem=aitem;
- if(OpenMWin(&MenuWindow,&MenuText[4])) return(1);
- MType=0;
- SY=0;
- SetMDefines();
- ActivateGadget(&MEingabe,Mwin,NULL);
-
- do
- {
- Wait(1L << Mwin->UserPort->mp_SigBit);
- while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
- {
- HolMsg(Mmsg);
- switch(class)
- {
- case MOUSEMOVE: SY=1;
- break;
- case GADGETUP:
- switch(Id)
- {
- case 0: quit=TRUE;
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- if(MType==0)
- {
- if(firstM) RetteMenu();
- AktM();
- if(helpM==NULL) NewMenu();
- SetMDefines();
- ActivateGadget(&MEingabe,Mwin,NULL);
- break;
- }
- if(MType==1)
- {
- if(aitem) RetteItem(1);
- AktI();
- aitem=helpJ;
- if(helpJ==NULL) NewItem();
- SetIDefines();
- ActivateGadget(&IEingabe,Mwin,NULL);
- break;
- }
- if(asub) RetteItem(1);
- AktI();
- asub=helpJ;
- if(helpJ==NULL) NewSub();
- SetIDefines();
- ActivateGadget(&IEingabe,Mwin,NULL);
- break;
- /* Zum Menu */
- case 80: if(MType==0) break;
- MWinOn(Mwin);
- OpenMWin(&MenuWindow,&MenuText[4]);
- MType=0;
- SetMDefines();
- ShowMenu();
- ActivateGadget(&MEingabe,Mwin,NULL);
- break;
- /* Zum Item */
- case 81: if(amenu==NULL || MType==1) break;
- MWinOn(Mwin);
- OpenMWin(&ItemWindow,&MenuText[13]);
- MType=1;
- SetIDefines();
- ShowItem();
- ActivateGadget(&IEingabe,Mwin,NULL);
- break;
- /* Zum Sub */
- case 82: if(aitem==NULL || MType==2) break;
- MWinOn(Mwin);
- OpenMWin(&ItemWindow,&MenuText[14]);
- MType=2;
- SetIDefines();
- ShowItem();
- ActivateGadget(&IEingabe,Mwin,NULL);
- break;
- /* Menu-Auto */
- case 76: Mauto ^= 1;
- break;
- /* Item-Image */
- case 29: DeIm(2);
- break;
- /* Select-Image */
- case 28: DeIm(3);
- break;
- /* OK - Menu */
- case 11: if(MType==0)
- {
- if(amenu) RetteMenu();
- break;
- }
- if(MType==1)
- {
- if(aitem) RetteItem(1);
- break;
- }
- if(asub) RetteItem(1);
- break;
- /* LĂ–SCHEN - Menu */
- case 13: if(MType==0)
- {
- if(amenu)
- {
- if(Error(19,1,0)==0) break;
- LoeschM();
-
- if(helpM==NULL)
- {
- NoMenu();
- WMItem5.Flags=ItemOff;
- WMItem5b.Flags=ItemOff;
- }
- MAus();
- DelMenu();
- amenu=helpM;
- MenuOn(0);
- SetMDefines();
- }
- break;
- }
- if(MType==1)
- {
- if(aitem)
- {
- if(Error(21,1,0)==0) break;
- LoeschI(1);
- }
- break;
- }
- if(asub)
- {
- if(Error(22,1,0)==0) break;
- LoeschI(1);
- }
- break;
- case 46: strcpy(Icom,DEPTHBuff);
- break;
- case 45:
- case 14: Mleft=LEFTInfo.LongInt;
- break;
- case 15:
- case 44: Mtop=TOPInfo.LongInt;
- break;
- case 43:
- case 19: Mwidth=WIDTHInfo.LongInt;
- break;
- case 42:
- case 20: Mheight=HEIGHTInfo.LongInt;
- break;
- /* MENUENABLED */
- case 21: Mflag ^= 1;
- break;
- /* ITEMFLAGS */
- case 35:
- case 36:
- case 37:
- case 38: Mflag ^= MFLAGS[Id-35];
- break;
- /* ItemText */
- case 33: DeTx(MType+1);
- break;
- break;
- /* SelectText */
- case 34: DeTx(MType+3);
- break;
- } /* switch Id */
- break;
- case GADGETDOWN:
- switch(Id)
- {
- /* PLATZ-MENU */
- case 12:
- if(amenu)
- {
- if(amenu == firstM && amenu == lastM)
- break;
- PlaceMenu();
- }
- break;
- /* PLATZ-ITEM */
- case 32:
- if(MType==1 && aitem != NULL)
- {
- if(aitem == firstI && aitem == lastI)
- break;
- PlaceItem();
- break;
- }
- if(asub)
- {
- if(asub == Sfirst && asub == Slast)
- break;
- PlaceItem();
- }
- break;
- case 39:
- case 40:
- case 41:
- Id-=35;
- Mflag = (Mflag & 0xFF3F)|MFLAGS[Id];
- SetPen(Mrp,0,JAM1);
- RectFill(Mrp,6,128,93,160);
- SetDrMd(Mrp,COMPLEMENT);
- RefreshGList(&IFlag[6],Mwin,NULL,3);
- Id=(Id-4)*12;
- RectFill(Mrp,6,128+Id,93,136+Id);
- break;
- /* EXCLUDE-ITEM */
- case 27: ExcludeI();
- break;
- default: TestProp();
- break;
- } /* switch Id */
-
- }/* switch class */
- if(quit==FALSE) Modify();
- }
- }while(quit==FALSE); /* do */
- MWinOn(Mwin);
- WMsc->Font=&ZS8;
- ScreenToFront(sc);
- return(0);
- }
- VOID DeTx(UBYTE m)
- {
- i=0;
- if((MType==1 && aitem != NULL) || (MType==2 && asub != NULL))
- {
- MAus();
- if(DefText(m)) Error(0,1,1);
- ScreenToFront(activS);
- MenuOn(0);
- }
- }
- VOID DeIm(UBYTE m)
- {
- i=0;
- if(MType==1 && aitem != NULL) i=m;
- else
- {
- if(MType==2 && asub != NULL)
- i=m+2;
- }
- if(i)
- {
- MAus();
- DefImage(i);
- ScreenToFront(activS);
- ActivateWindow(Mwin);
- MenuOn(0);
- }
- }
- VOID TestProp()
- {
- switch(Id)
- {
- /* Prop-Menu */
- case 16: SY=1;
- break;
- /* Up-Menu */
- case 17: SY=2;
- break;
- case 18: SY=3;
- break;
- }
- }
- VOID Modify()
- {
- if(SY==1)
- {
- if(MType==0)
- {
- if(Manz > 9)
- {
- i=Mnr;
- Mnr=((MenuPropInfo.VertPot+1)*(Manz-9)/65535);
- if(i!=Mnr) ShowMenu();
- }
- }
- if(MType==1)
- {
- if(Ianz > 9)
- {
- i=Inr;
- Inr=((MenuPropInfo.VertPot+1)*(Ianz-9)/65535);
- if(i!=Inr) ShowItem();
- }
- }
- if(MType==2)
- {
- if(Sanz > 9)
- {
- i=Snr;
- Snr=((MenuPropInfo.VertPot+1)*(Sanz-9)/65535);
- if(i!=Snr) ShowItem();
- }
- }
- SY=0;
- }
- if(SY > 1)
- {
- while(class != GADGETUP)
- {
- if(SY==2)
- {
- if(MType==0)
- {
- if(Mnr)
- {
- Mnr--;
- SetMWert();
- }
- }
- if(MType==1)
- {
- if(Inr)
- {
- Inr--;
- SetIWert();
- }
- }
- if(MType==2)
- {
- if(Snr)
- {
- Snr--;
- SetSWert();
- }
- }
- }
- else
- {
- if(MType==0)
- {
- if((Mnr+9)<Manz)
- {
- Mnr++;
- SetMWert();
- }
- }
- if(MType==1)
- {
- if((Inr+9)<Ianz)
- {
- Inr++;
- SetIWert();
- }
- }
- if(MType==2)
- {
- if((Snr+9)<Sanz)
- {
- Snr++;
- SetSWert();
- }
- }
- }
- GetMessage(Mwin);
- }
- SY=0;
- }
- }
- VOID NewExclude()
- {
- struct MyItem *item1;
- actS=amenu->FirstItem;
- if(MType==2) actS=aitem->Sub;
- actI=actS;
- while(actS)
- {
- if(actS->Exclude)
- {
- item1=actI;
- write=0;
- read=1;
- while(item1)
- {
- if(actS->Exclude & item1->Bit)
- write |= read;
- read = read << 1;
- item1=item1->Next;
- }
- actS->Exclude=write;
- }
- actS=actS->Next;
- }
- NewBit();
- }
- USHORT ExcludeI()
- {
- UBYTE POK=1;
- if(MType==1 && aitem == NULL) return(0);
- if(MType==2 && asub == NULL) return(0);
- SetDrMd(Mrp,COMPLEMENT);
- RectFill(Mrp,173,100,232,111);
- SY=0;
- do
- {
- Wait(1L << Mwin->UserPort->mp_SigBit);
- while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
- {
- HolMsg(Mmsg);
- switch(class)
- {
- case MOUSEMOVE: SY=1;
- break;
- case GADGETUP:
- if(Id > 0 && Id < 11)
- {
- actS=aitem;
- if(MType==2) actS=asub;
- AktI();
- if(helpJ != NULL && helpJ != actS)
- {
- actS->Exclude ^= helpJ->Bit;
- ShowItem();
- MenuOn(1);
- }
- }
- break;
- case GADGETDOWN:
- if(Id==27) POK=0;
- else TestProp();
- }
- Modify();
- }
- } while(POK==1);
- SetDrMd(Mrp,COMPLEMENT);
- RectFill(Mrp,173,100,232,111);
- return(0);
- }
- VOID NewWidth()
- {
- i=0;
- actI=aitem->Sub;
- if(MType==1) actI=amenu->FirstItem;
- actS=actI;
- while(actI)
- {
- if(actI->IstWidth > i) i=actI->IstWidth;
- actI=actI->Next;
- }
- while(actS)
- {
- if(actS->Auto)
- {
- actS->Width = i;
- actI=actS->Sub;
- while(actI)
- {
- if(actI->Auto) actI->LeftEdge=i;
- actI=actI->Next;
- }
- }
- actS=actS->Next;
- }
- }
- VOID LoeschM()
- {
- if(amenu->Parent)
- {
- if(amenu->Next)
- {
- NewLeftM();
- helpM=amenu->Next;
- amenu->Next->Parent=amenu->Parent;
- }
- else
- {
- helpM=amenu->Parent;
- lastM=helpM;
- }
- amenu->Parent->Next=amenu->Next;
- }
- else
- {
- if(amenu->Next)
- {
- NewLeftM();
- firstM=amenu->Next;
- helpM=firstM;
- helpM->Parent=NULL;
- awin->MenuStrip=firstM;
- }
- else helpM=NULL;
- }
- Manz--;
- if(Mnr>0 && (Mnr+9)>Manz) Mnr--;
- }
- VOID LoeschI(UBYTE m)
- {
- actI=asub;
- if(MType==1) actI=aitem;
- if(actI->Parent)
- {
- if(actI->Next)
- {
- NewTop();
- helpJ=actI->Next;
- actI->Next->Parent=actI->Parent;
- }
- else
- {
- helpJ=actI->Parent;
- if(MType==1) lastI=helpJ;
- else Slast=helpJ;
- }
- actI->Parent->Next=actI->Next;
- }
- else
- {
- if(actI->Next)
- {
- NewTop();
- if(MType==1)
- {
- firstI=actI->Next;
- amenu->FirstItem=firstI;
- }
- else
- {
- Sfirst=actI->Next;
- aitem->Sub=Sfirst;
- }
- helpJ=actI->Next;
- helpJ->Parent=NULL;
- }
- else helpJ=NULL;
- }
- if(helpJ==NULL)
- {
- if(MType==1) NoItem();
- else NoSub();
- }
- else
- {
- NewExclude();
- NewWidth();
- }
- MAus();
- if(MType==1)
- {
- if(m)
- {
- DelItem();
- aitem=helpJ;
- SetIDefines();
- }
- Ianz--;
- if(Inr>0 && (Inr+9)>Ianz) Inr--;
- }
- else
- {
- if(m)
- {
- DelSub();
- asub=helpJ;
- SetIDefines();
- }
- Sanz--;
- if(Snr>0 && (Snr+9)>Sanz) Snr--;
- }
- if(m) MenuOn(0);
- }
- VOID PlaceMenu()
- {
- UBYTE POK=1;
- actM=amenu;
- SetPen(Mrp,1,JAM1|COMPLEMENT);
- RectFill(Mrp,50,186,137,194);
- LoeschM();
- SetMWert();
- do
- {
- Wait(1L << Mwin->UserPort->mp_SigBit);
- while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
- {
- HolMsg(Mmsg);
- switch(class)
- {
- case GADGETUP:
- if(Id > 0 && Id < 11)
- {
- AktM();
- if(helpM==NULL)
- {
- lastM->Next=actM;
- actM->Parent=lastM;
- actM->Next=NULL;
- actM->LeftEdge=lastM->LeftEdge+lastM->Width;
- lastM=actM;
- }
- else
- {
- actM->Parent=helpM->Parent;
- if(helpM->Parent)
- helpM->Parent->Next=actM;
- else
- {
- firstM=actM;
- awin->MenuStrip=firstM;
- }
- actM->Next=helpM;
- helpM->Parent=actM;
- actM->LeftEdge=helpM->LeftEdge;
- while(helpM)
- {
- helpM->LeftEdge+=actM->Width;
- helpM=helpM->Next;
- }
- }
- POK=0;
- amenu=actM;
- }
- break;
- case MOUSEMOVE: SY=1;
- break;
- case GADGETDOWN:
- TestProp();
- break;
- }
- Modify();
- }
- }while(POK==1);
- Manz++;
- if((Mnr+9)<Manz) Mnr++;
- MenuOn(1);
- SetDrMd(Mrp,JAM1|COMPLEMENT);
- RectFill(Mrp,50,186,137,194);
- SetMDefines();
- }
- VOID HolMsg(struct IntuiMessage *msg)
- {
- class=msg->Class;
- code=msg->Code;
- gad=(struct Gadget*)msg->IAddress;
- Id=gad->GadgetID;
- ReplyMsg(msg);
- }
- VOID PlaceItem()
- {
- UBYTE POK=1;
- actI=asub;
- if(MType==1) actI=aitem;
- SetPen(Mrp,1,JAM1|COMPLEMENT);
- RectFill(Mrp,122,138,209,146);
- LoeschI(0);
- if(MType==1) SetIWert();
- else SetSWert();
- do
- {
- Wait(1L << Mwin->UserPort->mp_SigBit);
- while(Mmsg=(struct IntuiMessage*)GetMsg(Mwin->UserPort))
- {
- HolMsg(Mmsg);
- switch(class)
- {
- case GADGETUP:
- if(Id > 0 && Id < 11)
- {
- AktI();
- if(helpJ==NULL)
- {
- if(MType==1)
- {
- lastI->Next=actI;
- actI->Parent=lastI;
- actI->TopEdge=lastI->TopEdge+lastI->Height;
- lastI=actI;
- }
- else
- {
- Slast->Next=actI;
- actI->Parent=Slast;
- actI->TopEdge=Slast->TopEdge+Slast->Height;
- Slast=actI;
- }
- actI->Next=NULL;
-
- }
- else
- {
- actI->Parent=helpJ->Parent;
- if(helpJ->Parent)
- helpJ->Parent->Next=actI;
- else
- {
- if(MType==1)
- {
- firstI=actI;
- amenu->FirstItem=firstI;
- }
- else
- {
- Sfirst=actI;
- aitem->Sub=Sfirst;
- }
- }
- actI->Next=helpJ;
- helpJ->Parent=actI;
- actI->TopEdge=helpJ->TopEdge;
- while(helpJ)
- {
- helpJ->TopEdge+=actI->Height;
- helpJ=helpJ->Next;
- }
- }
- POK=0;
- }
- break;
- case MOUSEMOVE: SY=1;
- break;
- case GADGETDOWN: TestProp();
- break;
- }
- Modify();
- }
- }while(POK==1);
- if(MType==1)
- {
- Ianz++;
- if((Inr+9)<Ianz) Inr++;
- aitem=actI;
- SetIDefines();
- }
- else
- {
- Sanz++;
- if((Snr+9)<Sanz) Snr++;
- asub=actI;
- SetIDefines();
- }
- NewExclude();
- MenuOn(1);
- SetDrMd(Mrp,JAM1|COMPLEMENT);
- RectFill(Mrp,122,138,209,146);
- }
- VOID AktM()
- {
- helpM=awin->MenuStrip;
- if(helpM)
- {
- for(i=0; i<Mnr; i++)
- helpM=helpM->Next;
- }
- i=1;
- amenu=helpM;
- while(i != Id && amenu != NULL)
- {
- helpM=helpM->Next;
- amenu=helpM;
- i++;
- }
- }
- VOID AktI()
- {
- helpJ=aitem->Sub;
- j=Snr;
- if(MType==1)
- {
- helpJ=amenu->FirstItem;
- j=Inr;
- }
- if(helpJ)
- {
- for(i=0; i<j; i++)
- helpJ=helpJ->Next;
- i=1;
- while(i != Id && helpJ != NULL)
- {
- helpJ=helpJ->Next;
- i++;
- }
- }
- }
- VOID NewLeftI()
- {
- while(helpT)
- {
- helpT->LeftEdge=0;
- if(actI->Flags & CHECKIT)
- {
- helpT->LeftEdge=19;
- if(awin->CheckMark)
- helpT->LeftEdge=awin->CheckMark->Width+4;
- }
- helpT=helpT->NextText;
- }
- }
- VOID NewLeftM()
- {
- helpM=amenu->Next;
- helpM->LeftEdge=amenu->LeftEdge;
- helpM=helpM->Next;
- while(helpM)
- {
- helpM->LeftEdge=helpM->Parent->LeftEdge+helpM->Parent->Width;
- helpM=helpM->Next;
- }
- }
- VOID NewTop()
- {
- helpJ=asub->Next;
- helpJ->TopEdge=asub->TopEdge;
- if(MType==1)
- {
- helpJ=aitem->Next;
- helpJ->TopEdge=aitem->TopEdge;
- }
- helpJ=helpJ->Next;
- while(helpJ)
- {
- helpJ->TopEdge=helpJ->Parent->TopEdge+helpJ->Parent->Height;
- helpJ=helpJ->Next;
- }
- }
- VOID NewTopI()
- {
- helpJ=asub->Next;
- if(MType==1) helpJ=aitem->Next;
- while(helpJ)
- {
- if(helpJ->Auto)
- helpJ->TopEdge=helpJ->Parent->TopEdge+helpJ->Parent->Height;
- helpJ=helpJ->Next;
- }
- }
- VOID DelMenuAll()
- {
- amenu=awin->MenuStrip;
- while(amenu)
- {
- helpM=amenu->Next;
- DelMenu();
- amenu=helpM;
- }
- NoMenu();
- }
- VOID NoMenu()
- {
- firstM=NULL;
- lastM=NULL;
- awin->MenuStrip=NULL;
-
- }
- VOID NoItem()
- {
- firstI=NULL;
- lastI=NULL;
- amenu->FirstItem=NULL;
- }
- VOID NoSub()
- {
- Sfirst=NULL;
- Slast=NULL;
- aitem->Sub=NULL;
- }
- VOID DelMenu()
- {
- aitem=amenu->FirstItem;
- while(aitem)
- {
- actI=aitem->Next;
- DelItem();
- aitem=actI;
- }
- FreeMem(amenu,sizeof(struct MyMenu));
- }
- VOID DelItem()
- {
- asub=aitem->Sub;
- while(asub)
- {
- actS=asub->Next;
- DelSub();
- asub=actS;
- }
- if(aitem->ItemText) DelText(aitem->ItemText);
- if(aitem->SelectText) DelText(aitem->SelectText);
- helpI=aitem->ItemImage;
- DelImage(2);
- helpI=aitem->SelectImage;
- DelImage(3);
- FreeMem(aitem,sizeof(struct MyItem));
- }
- VOID DelSub()
- {
- if(asub->ItemText) DelText(asub->ItemText);
- if(asub->SelectText) DelText(asub->SelectText);
- helpI=asub->ItemImage;
- DelImage(4);
- helpI=asub->SelectImage;
- DelImage(5);
- FreeMem(asub,sizeof(struct MyItem));
- }
- VOID MAus()
- {
- if(Mwin->MenuStrip) ClearMenuStrip(Mwin);
- }
- VOID MEin()
- {
- if(awin->MenuStrip) SetMenuStrip(Mwin,&awin->MenuStrip->Menu);
- }
- VOID RetteMenu()
- {
- if(Mauto)
- {
- Mleft=0;
- Mtop=0;
- Mheight=8;
- if(TxS==10) Mheight=9;
- Mwidth=(strlen(TITLEBuff)*TxS)+7;
- if(amenu->Parent)
- {
- Mleft=(amenu->Parent->LeftEdge+amenu->Parent->Width)+7;
- Mtop=amenu->Parent->TopEdge;
- Mheight=amenu->Parent->Height;
- }
- InBuffer();
- RefreshGList(&MLeft,Mwin,NULL,4);
- }
- amenu->Width=Mwidth;
- amenu->Height=Mheight;
- amenu->LeftEdge=Mleft;
- amenu->TopEdge=Mtop;
- amenu->Flags=Mflag;
- amenu->Auto=Mauto;
- strcpy(amenu->MName,TITLEBuff);
- MenuOn(1);
- ShowMenu();
- SaveOk=1;
- }
- VOID InBuffer()
- {
- sprintf(LEFTBuff,"%d",Mleft);
- sprintf(TOPBuff,"%d",Mtop);
- sprintf(HEIGHTBuff,"%d",Mheight);
- sprintf(WIDTHBuff,"%d",Mwidth);
- }
- VOID RetteItem(UBYTE m)
- {
- struct MyItem *item;
- actI=asub;
- if(MType==1) actI=aitem;
- actI->Flags=Mflag;
- actI->Auto=Mauto;
- actI->IstWidth=Mwidth;
- strcpy(actI->ItemName,TITLEBuff);
- actI->Width=Mwidth;
- actI->Height=Mheight;
- actI->LeftEdge=Mleft;
- actI->TopEdge=Mtop;
- actI->Command=0;
- if(strlen(Icom)) actI->Command=Icom[0];
- if(Mauto)
- {
- item=actI;
- ItemAuto();
- actI=item;
- Mwidth=actI->Width;
- Mheight=actI->Height;
- Mleft=actI->LeftEdge;
- Mtop=actI->TopEdge;
- InBuffer();
- RefreshGList(&ILeft,Mwin,NULL,4);
- }
- NewWidth();
- NewTopI();
- if(m)
- {
- ShowItem();
- MenuOn(1);
- }
- SaveOk=1;
- }
- VOID ItemAuto()
- {
- actI=aitem;
- actI->LeftEdge=0;
- if(MType==2)
- {
- actI=asub;
- actI->LeftEdge=aitem->Width;
- }
- actI->TopEdge=0;
- actI->Height=8;
- if(TxS==10) actI->Height=9;
- if(actI->Parent)
- {
- actI->TopEdge=actI->Parent->TopEdge+actI->Parent->Height;
- actI->LeftEdge=actI->Parent->LeftEdge;
- }
- if(actI->ItemImage==NULL)
- {
- if(actI->ItemText)
- actI->Width=strlen(actI->ItemText->IText)*TxS;
- else actI->Width=strlen(TITLEBuff)*TxS;
- }
- else
- {
- i=0;
- j=0;
- x=0;
- y=0;
- actI->ItemImage->LeftEdge=0;
- actI->ItemImage->TopEdge=0;
- i=actI->ItemImage->Height;
- x=actI->ItemImage->Width;
- if(actI->Flags & CHECKIT)
- {
- d=19;
- if(awin->CheckMark)
- d=awin->CheckMark->Width+4;
- actI->ItemImage->LeftEdge = d;
- }
- if(actI->SelectImage && actI->ItemImage)
- {
- actI->SelectImage->LeftEdge=0;
- actI->SelectImage->TopEdge=0;
- j=actI->SelectImage->Height;
- y=actI->SelectImage->Width;
- if(actI->Flags & CHECKIT)
- {
- d=19;
- if(awin->CheckMark)
- d=awin->CheckMark->Width+4;
- actI->SelectImage->LeftEdge = d;
- }
- }
- if(i < j) actI->Height=j;
- else actI->Height=i;
- if(x < y) actI->Width=y;
- else actI->Width=x;
- }
- if(actI->Flags & CHECKIT)
- {
- d=19;
- if(awin->CheckMark)
- {
- helpI=awin->CheckMark;
- d=helpI->Width+4;
- if(actI->Height < helpI->Height)
- actI->Height=helpI->Height;
- }
- actI->Width+=d;
- }
- if(actI->Command)
- {
- if(TxS==8) actI->Width+=37;
- else actI->Width+=40;
- }
- actI->IstWidth=actI->Width;
- helpT=actI->ItemText;
- NewLeftI();
- helpT=actI->SelectText;
- NewLeftI();
- NewWidth();
- NewTopI();
- }
- VOID MenuOn(UBYTE m)
- {
- if(m) MAus();
- MakeMenu();
- MEin();
- }
- VOID SetMDefines()
- {
- MEingabeInfo.DispPos=0;
- TITLEBuff[0]=0;
- Mwidth=0;
- Mheight=0;
- Mflag=MENUENABLED;
- Mleft=0;
- Mtop=0;
- Mauto=1;
- if(amenu)
- {
- strcpy(TITLEBuff,amenu->MName);
- Mtop=amenu->TopEdge;
- Mleft=amenu->LeftEdge;
- Mwidth=amenu->Width;
- Mheight=amenu->Height;
- Mflag=amenu->Flags;
- Mauto=amenu->Auto;
- }
- InBuffer();
- MFlag.Flags=NULL;
- if(Mflag) MFlag.Flags=SELECTED;
- MAuto.Flags=GRELRIGHT;
- if(Mauto) MAuto.Flags=GRELRIGHT|SELECTED;
- SetPen(Mrp,0,JAM1);
- RectFill(Mrp,50,171,137,179);
- RectFill(Mrp,190,89,249,108);
- RefreshGList(&MEingabe,Mwin,NULL,8);
- SetMWert();
- if(OldMenu != amenu)
- {
- HolItem();
- OldMenu=amenu;
- }
- }
- VOID SetIDefines()
- {
- actI=aitem;
- if(MType==2) actI=asub;
- MEingabeInfo.DispPos=0;
- TITLEBuff[0]=0;
- Mtop=0;
- Mleft=0;
- Mwidth=0;
- Mheight=0;
- Mflag=ITEMENABLED|HIGHCOMP;
- Mauto=1;
- if(actI)
- {
- strcpy(TITLEBuff,actI->ItemName);
- Mtop=actI->TopEdge;
- Mleft=actI->LeftEdge;
- Mwidth=actI->Width;
- Mheight=actI->Height;
- Mflag=actI->Flags;
- Mauto=actI->Auto;
- Icom[0]=0;
- if(actI->Command)
- {
- Icom[0]=actI->Command;
- Icom[1]='\0';
- }
- }
- InBuffer();
- strcpy(DEPTHBuff,Icom);
- MAuto.Flags=GRELRIGHT;
- if(Mauto) MAuto.Flags=GRELRIGHT|SELECTED;
- SetPen(Mrp,0,JAM1);
- RectFill(Mrp,6,128,93,196);
- RectFill(Mrp,122,122,209,130);
- RectFill(Mrp,240,89,299,108);
- RefreshGList(&MAuto,Mwin,NULL,1);
- for(i=0; i<4; i++)
- {
- IFlag[i].Flags=NULL;
- if(Mflag & MFLAGS[i]) IFlag[i].Flags=SELECTED;
- }
- if(MType==1) SetIWert();
- else SetSWert();
- RefreshGList(&IEingabe,Mwin,NULL,13);
- SetDrMd(Mrp,JAM1|COMPLEMENT);
- for(i=4; i<7; i++)
- {
- y=128+((i-4)*12);
- if((Mflag & MFLAGS[i]) == MFLAGS[i])
- RectFill(Mrp,6,y,93,y+8);
- }
- if(MType==1)
- {
- if(OldItem != aitem)
- {
- HolSub();
- OldItem=aitem;
- }
- }
- }
- VOID HolItem()
- {
- aitem=NULL;
- if(amenu) aitem=amenu->FirstItem;
- firstI=aitem;
- lastI=aitem;
- Inr=0;
- Ianz=0;
- while(aitem)
- {
- lastI=aitem;
- Ianz++;
- aitem=aitem->Next;
- if(Ianz > 9) Inr++;
- }
- aitem=lastI;
- if(aitem==NULL) NoItem();
- else HolSub();
- }
- VOID HolSub()
- {
- asub=NULL;
- if(aitem) asub=aitem->Sub;
- Sfirst=asub;
- Slast=asub;
- Snr=0;
- Sanz=0;
- while(asub)
- {
- Slast=asub;
- Sanz++;
- asub=asub->Next;
- if(Sanz > 9) Snr++;
- }
- asub=Slast;
- if(asub==NULL) NoSub();
- }
- VOID ShowMenu()
- {
- SetPen(Mrp,1,JAM2);
- SetBPen(Mrp,2);
- helpM=awin->MenuStrip;
- for(i=0; i<Mnr; i++)
- helpM=helpM->Next;
- for(i=0; i<10; i++)
- {
- LEER[0]=0;
- Move(Mrp,34,26+(i*8));
- if(helpM)
- {
- strncpy(LEER,helpM->MName,15);
- helpM=helpM->Next;
- }
- for(j=strlen(LEER); j<15; j++)
- strcat(LEER," ");
- Text(Mrp,LEER,15);
- }
- }
- VOID NewBit()
- {
- actI=amenu->FirstItem;
- if(MType==2) actI=aitem->Sub;
- read=1;
- while(actI)
- {
- actI->Bit=read;
- read = read << 1;
- actI=actI->Next;
- }
- }
- VOID ShowItem()
- {
- SetPen(Mrp,1,JAM2);
- SetBPen(Mrp,2);
- actI=aitem;
- helpJ=amenu->FirstItem;
- nr=Inr;
- if(MType==2)
- {
- actI=asub;
- helpJ=aitem->Sub;
- nr=Snr;
- }
- for(i=0; i<nr; i++)
- helpJ=helpJ->Next;
- for(i=0; i<10; i++)
- {
- LEER[0]=0;
- y=26+(i*8);
- SetAPen(Mrp,1);
- Move(Mrp,34,y);
- if(helpJ) strncpy(LEER,helpJ->ItemName,15);
- for(j=strlen(LEER); j<15; j++)
- strcat(LEER," ");
- Text(Mrp,LEER,15);
- Move(Mrp,155,y);
- SetAPen(Mrp,3);
- if(helpJ)
- {
- if(actI->Exclude & helpJ->Bit) Text(Mrp,"E",1);
- else Text(Mrp,"-",1);
- helpJ=helpJ->Next;
- }
- else Text(Mrp," ",1);
- }
- }
- VOID SetPen(struct RastPort *r,UBYTE c,UBYTE m)
- {
- SetAPen(r,c);
- SetDrMd(r,m);
- }
- VOID SetMWert()
- {
- ShowMenu();
- SetWert(Mnr,Manz,Mwin,&MenuProp,&MenuPropInfo);
- }
- VOID SetIWert()
- {
- ShowItem();
- SetWert(Inr,Ianz,Mwin,&MenuProp,&MenuPropInfo);
- }
- VOID SetSWert()
- {
- ShowItem();
- SetWert(Snr,Sanz,Mwin,&MenuProp,&MenuPropInfo);
- }
- VOID SetWert(USHORT no,USHORT fmax,struct Window *win,
- struct Gadget *gadget,struct PropInfo *info)
- {
- USHORT VB=0;
- if(no) VB=65535*no/(fmax-9);
- size=65535;
- if(fmax>9) size=65535*9/fmax;
- info->VertPot=VB;
- info->VertBody=size;
- RefreshGList(gadget,win,NULL,1);
- }
- VOID MakeMenu()
- {
- helpM=awin->MenuStrip;
- while(helpM)
- {
- helpM->Menu.NextMenu=NULL;
- if(helpM->Parent)
- helpM->Parent->Menu.NextMenu=&helpM->Menu;
- helpM->Menu.LeftEdge=helpM->LeftEdge;
- helpM->Menu.TopEdge=helpM->TopEdge;
- helpM->Menu.Width=helpM->Width;
- helpM->Menu.Height=helpM->Height;
- helpM->Menu.Flags=helpM->Flags;
- helpM->Menu.MenuName=helpM->MName;
- helpM->Menu.FirstItem=NULL;
- if(helpM->FirstItem) MakeMenuItem();
- helpM=helpM->Next;
- }
- }
- VOID MakeItem()
- {
- actI->Item.NextItem=NULL;
- if(actI->Parent)
- actI->Parent->Item.NextItem=&actI->Item;
- actI->Item.LeftEdge=actI->LeftEdge;
- actI->Item.TopEdge=actI->TopEdge;
- actI->Item.Flags=actI->Flags;
- actI->Item.Width=actI->Width;
- actI->Item.Height=actI->Height;
- actI->Item.MutualExclude=actI->Exclude;
- actI->Item.ItemFill=NULL;
- actI->Item.SelectFill=NULL;
- if(actI->ItemText != NULL && actI->ItemImage==NULL)
- {
- helpT=actI->ItemText;
- MakeText();
- actI->Item.ItemFill=(APTR)&actI->ItemText->Text;
- actI->Item.Flags |= ITEMTEXT;
- if(actI->SelectText != NULL)
- {
- helpT=actI->SelectText;
- MakeText();
- actI->Item.SelectFill=(APTR)&actI->SelectText->Text;
- actI->Item.Flags &= 0xFF3F;
- }
- }
- if(actI->ItemImage)
- {
- helpI=actI->ItemImage;
- MakeImage();
- actI->Item.ItemFill=(APTR)&actI->ItemImage->Image;
- actI->Item.Flags &= 0xFFFD;
- if((actI->Flags & HIGHFLAGS)==0)
- actI->Item.Flags |= HIGHCOMP;
- if(actI->SelectImage)
- {
- helpI=actI->SelectImage;
- MakeImage();
- actI->Item.SelectFill=(APTR)&actI->SelectImage->Image;
- actI->Item.Flags &= 0xFF3D;
- }
- }
- actI->Item.Command=actI->Command;
- if(actI->Command) actI->Item.Flags |= COMMSEQ;
- actI->Item.SubItem=NULL;
- actI->Item.NextSelect=MENUNULL;
- }
- VOID MakeMenuItem()
- {
- helpJ=helpM->FirstItem;
- while(helpJ)
- {
- actI=helpJ;
- MakeItem();
- if(helpJ->Sub) MakeSub();
- helpJ=helpJ->Next;
- }
- helpM->Menu.FirstItem=&helpM->FirstItem->Item;
- }
- VOID MakeSub()
- {
- Shelp=helpJ->Sub;
- while(Shelp)
- {
- actI=Shelp;
- MakeItem();
- Shelp=Shelp->Next;
- }
- helpJ->Item.SubItem=&helpJ->Sub->Item;
- }
- USHORT NoText()
- {
- firstT=NULL;
- lastT=NULL;
- left=0;
- top=0;
- dm=COMPLEMENT;
- front=3;
- back=1;
- style=0;
- f1=1;
- if(TxS==10) f1=2;
- if(NewText()) return(1);
- return(0);
- }
- USHORT NewMenu()
- {
- if(Manz==31)
- {
- Error(23,1,1);
- amenu=lastM;
- return(1);
- }
- if(amenu=(struct MyMenu *)
- AllocMem(sizeof(struct MyMenu),MEMF_CLEAR|MEMF_PUBLIC))
- {
- Manz++;
- if((Mnr+9)<Manz) Mnr++;
- if(firstM==NULL)
- {
- firstM=amenu;
- awin->MenuStrip=firstM;
- }
- else
- {
- lastM->Next=amenu;
- amenu->LeftEdge=7+(lastM->LeftEdge+lastM->Width);
- amenu->Height=lastM->Height;
- amenu->TopEdge=lastM->TopEdge;
- }
- amenu->Parent=lastM;
- amenu->Flags=MENUENABLED;
- amenu->Auto=1;
- sprintf(LEER,"%d",Manz);
- strcpy(amenu->MName,"Menu_");
- strcat(amenu->MName,LEER);
- amenu->Width=(strlen(amenu->MName)*TxS)+7;
- lastM=amenu;
- WMItem5.Flags=ItemOn;
- WMItem5b.Flags=ItemOn;
- MenuOn(1);
- HolItem();
- OldMenu=amenu;
- OldItem=aitem;
- return(0);
- }
- Error(0,1,1);
- amenu=lastM;
- return(1);
- }
- USHORT NewItem()
- {
- if(Ianz==63)
- {
- Error(24,1,1);
- aitem=lastI;
- return(1);
- }
- if(aitem=(struct MyItem *)
- AllocMem(sizeof(struct MyItem),MEMF_CLEAR|MEMF_PUBLIC))
- {
- if(NoText())
- {
- FreeMem(aitem,sizeof(struct MyItem));
- aitem=lastI;
- Error(0,1,1);
- return(1);
- }
- Ianz++;
- if((Inr+9)<Ianz) Inr++;
- strcpy(aitem->ItemName,"Item_");
- sprintf(LEER,"%d",Ianz);
- strcat(aitem->ItemName,LEER);
- strcpy(TITLEBuff,aitem->ItemName);
- aitem->IstWidth=strlen(aitem->ItemName)*TxS;;
- aitem->Width=aitem->IstWidth;
- aitem->Height=8;
- if(TxS==10) aitem->Height=9;
- if(firstI==NULL)
- {
- firstI=aitem;
- amenu->FirstItem=firstI;
- aitem->Flags=HIGHCOMP|ITEMENABLED;
- }
- else
- {
- lastI->Next=aitem;
- aitem->LeftEdge=lastI->LeftEdge;
- aitem->TopEdge=(lastI->TopEdge+lastI->Height);
- aitem->Flags=lastI->Flags;
- if(lastI->Width > aitem->Width)
- aitem->Width=lastI->Width;
- }
- aitem->Parent=lastI;
- aitem->Auto=1;
- aitem->ItemText=firstT;
- strcpy(firstT->IText,aitem->ItemName);
- aitem->NextSelect=MENUNULL;
- lastI=aitem;
- MenuOn(1);
- NewBit();
- HolSub();
- OldItem=aitem;
- return(0);
- }
- Error(0,1,1);
- aitem=lastI;
- return(1);
- }
- USHORT NewSub()
- {
- if(Sanz==31)
- {
- Error(25,1,1);
- asub=Slast;
- return(1);
- }
- if(asub=(struct MyItem *)
- AllocMem(sizeof(struct MyItem),MEMF_CLEAR|MEMF_PUBLIC))
- {
- if(NoText())
- {
- FreeMem(asub,sizeof(struct MyItem));
- asub=Slast;
- Error(0,1,1);
- return(1);
- }
- Sanz++;
- if((Snr+9)<Sanz) Snr++;
- strcpy(asub->ItemName,"SubItem_");
- sprintf(LEER,"%d",Sanz);
- strcat(asub->ItemName,LEER);
- strcpy(TITLEBuff,asub->ItemName);
- asub->IstWidth=strlen(asub->ItemName)*TxS;
- asub->Width=asub->IstWidth;
- asub->Height=8;
- if(TxS==10) asub->Height=9;
- if(Sfirst==NULL)
- {
- Sfirst=asub;
- aitem->Sub=Sfirst;
- asub->LeftEdge=aitem->Width;
- asub->Flags=HIGHCOMP|ITEMENABLED;
- }
- else
- {
- Slast->Next=asub;
- asub->LeftEdge=Slast->LeftEdge;
- asub->TopEdge=(Slast->TopEdge+Slast->Height);
- asub->Flags=Slast->Flags;
- if(Slast->Width > asub->Width)
- asub->Width=Slast->Width;
- }
- asub->Parent=Slast;
- asub->Auto=1;
- asub->ItemText=firstT;
- strcpy(firstT->IText,asub->ItemName);
- asub->NextSelect=MENUNULL;
- Slast=asub;
- MenuOn(1);
- NewBit();
- return(0);
- }
- Error(0,1,1);
- asub=Slast;
- return(1);
- }
-
-